import reshandler from 'services/response-handler'
import Vue from 'vue'
/*
 * 车友会活动报名
 */
function makeData(response) {
    let resArr = []
    console.log(response.postList)
    response.postList && response.postList.forEach(val=>{
        let data =  {
			id:val.id,
			refId:val.refId,
			postType:val.postType,
			title: val.title,
			content: val.content,
			shop:{},
			name:val.author&&val.author.name,
			time:val.publishDate,
			attendNum:val.commentCount, // 评论数量
			star:val.followCount,   // 关注数量
			isSupport:val.hasFollow,
			images:val.images?[]:'',
			avatar:val.author.head?val.author.head:'',
			audios:val.audios?val.audios[0]:'',
			videos:val.videos?val.videos[0]:'',
			topics:val.topics,
			page:'community'
		}
		val.images && val.images.forEach(img=>{
			console.log(img)
			data.images.push(img)
		})
		resArr.push(data)
    })
  return resArr
}
export default function (params, success, fail) {
  // request 
  params = Object.assign({}, params, {
    methodName: "ListSpaceByTopic",
  })

  // invoke
  this.$.get(params)
    .then(reshandler.success(success, fail, makeData), reshandler.error(fail))
}
